
#include "zos_config.h"

#ifdef BOARD_USING_SPI_FLASH
#include  "zos.h"
#include  "w25qxx.h"

//要写入到W25Q16的字符串数组
const zos_uint8_t TEXT_Buffer[]={"QS-100 module spi flash test:1234567890"};
#define SIZE sizeof(TEXT_Buffer)	

zos_uint32_t FLASH_SIZE=32*1024*1024;	//FLASH 大小为32M字节
zos_uint8_t datatemp[SIZE];

int demo_spi_flash(int argc, char *argv[])
{
    w25qxx_init();

    while(w25qxx_read_ID()!=W25Q128)								//检测不到W25Q128
	{
		zos_printf("W25Q128 Check Failed!\r\n");
		zos_task_delay(500);
		zos_printf("Please Check!        \r\n");
		zos_task_delay(500);
	}
	zos_printf("W25Q128 Ready!\r\n"); 
	zos_printf("Start Write W25Q128....\r\n");
	w25qxx_write(FLASH_SIZE-100,TEXT_Buffer,SIZE);		//从倒数第100个地址处开始,写入SIZE长度的数据
	zos_printf("W25Q256 Write Finished!\r\n");	//提示传送完成
	zos_task_delay(1000);
 	zos_printf("Start Read W25Q128.... \r\n");
	w25qxx_read(FLASH_SIZE-100,datatemp,SIZE);					//从倒数第100个地址处开始,读出SIZE个字节
	zos_printf("The Data Readed Is:   ");	//提示传送完成
	zos_printf("%s\r\n",datatemp);					//显示读到的字符串

	return ZOS_EOK;
}

#include "shell.h"

SHELL_EXPORT_CMD(demo_spi_flash,demo_spi_flash, spi flash demo);

#endif




















